<template>
  <div>
    <div
        :style='{"width":"100%","padding":"0px 7%","margin":"0px auto 10px","borderRadius":"0px","background":"#99cc99","height":"40px"}'
        class="breadcrumb-preview">
      <el-breadcrumb :separator="'Ξ'" :style='{"fontSize":"14px","lineHeight":"40px"}'>
        <el-breadcrumb-item>首页</el-breadcrumb-item>
        <el-breadcrumb-item v-for="(item, index) in breadcrumbItem" :key="index">{{ item.name }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="breadcrumb-preview">
      <el-form :inline="true" :model="formSearch" class="list-form-pv" style="justify-content: center;display: flex;">
        <div class="section-btn">
          <el-form-item>
            <el-input v-model="title" placeholder="标题"></el-input>
          </el-form-item>
          <el-button type="primary" @click="getNewsList(1)"><i class="el-icon-search"></i>查询</el-button>
        </div>
      </el-form>
    </div>

    <div class="news-preview"
         :style='{"width":"100%","padding":"10px 0px","margin":"0px auto","position":"relative","background":"none"}'>


      <!-- 样式六 -->
      <div class="list6 index-pv1"
           :style='{"width":"100%","padding":"120px 7% 100px","background":"url(http://codegen.caihongy.cn/20230109/138a4d606eae4a168810cef229969885.png) no-repeat center top,url(http://codegen.caihongy.cn/20230109/b95aeae1c1294f398aefb7c6cd5b16de.png) no-repeat center top,url(http://codegen.caihongy.cn/20230109/5ffc803e6682418eb7f0b09a98e35527.png) no-repeat center bottom,#99CC99","height":"auto"}'>
        <div
            :style='{"width":"100%","margin":"10px 0 20px","background":"rgba(255,255,255,0)","justifyContent":"space-between","display":"flex","height":"auto"}'
            v-for="item in newsList" :key="item.id" @click="toNewsDetail(item)" class="list-item animation-box">
          <el-image
              :style='{"border":"1px solid #ddd","padding":"10px","objectFit":"contain","background":"rgba(255,255,255,.6)","display":"inline-block","width":"220px","height":"180px"}'
              :src="baseUrl + item.picture" :fit="fill"></el-image>
          <div class="item-info"
               :style='{"border":"1px solid #ddd","padding":"10px 0px","background":"rgba(255,255,255,1)","display":"inline-block","width":"calc(100% - 260px)","position":"relative","height":"100%"}'>
            <div
                :style='{"padding":"0 90px 0 10px","whiteSpace":"nowrap","overflow":"hidden","color":"#b58339","width":"calc(100% - 90px)","lineHeight":"32px","fontSize":"16px","textOverflow":"ellipsis"}'
                class="title ">{{ item.title }}
            </div>
            <div
                :style='{"padding":"0 10px","margin":"8px 0 0","overflow":"hidden","color":"#555","lineHeight":"24px","fontSize":"14px","textIndent":"2em","height":"120px"}'
                class="introduction ">{{ item.introduction }}
            </div>
            <div
                :style='{"lineHeight":"32px","fontSize":"12px","position":"absolute","right":"20px","color":"#b89e66","top":"10px"}'
                class="time ">{{ item.addtime }}
            </div>
            <div
                :style='{"padding":"0 10px","fontSize":"14px","lineHeight":"32px","color":"#fff","background":"#333","display":"none"}'
                class="tags">新闻动态
            </div>
          </div>
        </div>
      </div>


      <el-pagination
          background
          class="pagination"
          :pager-count="7"
          :page-size="pageSize"
          :page-sizes="pageSizes"
          prev-text="<"
          next-text=">"
          :hide-on-single-page="true"
          :layout='["total","prev","pager","next","sizes","jumper"].join()'
          :total="total"
          :style='{"padding":"0","margin":"10px auto","whiteSpace":"nowrap","color":"#333","textAlign":"center","width":"100%","fontWeight":"500"}'
          @current-change="curChange"
          @prev-click="prevClick"
          @next-click="nextClick"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  //数据集合
  data() {
    return {
      baseUrl: this.$config.baseUrl,
      breadcrumbItem: [
        {
          name: '新闻资讯'
        }
      ],
      newsList: [],
      total: 1,
      pageSize: 10, pageSizes: [10, 20, 30, 50],
      totalPage: 1,
      layouts: '',
      title: '',
    }
  },
  created() {
    this.getNewsList(1);
  },
  //方法集合
  methods: {
    getNewsList(page) {
      let params = {page, limit: this.pageSize, sort: 'addtime', order: 'desc'};
      let searchWhere = {};
      if (this.title != '') searchWhere.title = '%' + this.title + '%';
      this.$http.get('news/list', {params: Object.assign(params, searchWhere)}).then(res => {
        if (res.data.code == 0) {
          this.newsList = res.data.data.list;
          this.total = res.data.data.total;
          this.pageSize = res.data.data.pageSize;
          this.pageSizes = [this.pageSize, this.pageSize * 2, this.pageSize * 3, this.pageSize * 5];
          this.totalPage = res.data.data.totalPage;
        }
      });
    },
    curChange(page) {
      this.getNewsList(page);
    },
    prevClick(page) {
      this.getNewsList(page);
    },
    nextClick(page) {
      this.getNewsList(page);
    },
    toNewsDetail(item) {
      this.$router.push({path: '/index/newsDetail', query: {detailObj: JSON.stringify(item)}});
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.news-wrap {
  width: 1000px;
  margin: 0 auto;
}

.news-item {
  height: 200px;
  width: auto;
  margin-bottom: 30px;
  cursor: pointer;
}

.news-item-text {
  width: calc(100% - 215px);
  display: inline-block;
  vertical-align: top;
  margin-left: 15px;
}

.news-item-text-title {
  font-size: 16px;
  margin-bottom: 15px;
}

.news-item-text-intro {
  font-size: 14px;
  color: #666;
}

.hide1 {
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hide2 {
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hide3 {
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.index-pv1 .animation-box {
  transform: rotate(0deg) scale(1) skew(0deg, 0deg) translate3d(0px, 0px, 0px);
  z-index: initial;
}

.index-pv1 .animation-box:hover {
  transform: translate3d(0px, 0px, 0px);
  -webkit-perspective: 1000px;
  perspective: 1000px;
  transition: 0.3s;
  z-index: 1;
}

.index-pv1 .animation-box img {
  transform: rotate(0deg) scale(1) skew(0deg, 0deg) translate3d(0px, 0px, 0px);
}

.index-pv1 .animation-box img:hover {
  -webkit-perspective: 1000px;
  perspective: 1000px;
  transition: 0.3s;
}

.el-pagination ::v-deep .el-pagination__total {
  margin: 0 10px 0 0;
  color: #666;
  font-weight: 400;
  display: inline-block;
  vertical-align: top;
  font-size: 13px;
  line-height: 28px;
  height: 28px;
}

.el-pagination ::v-deep .btn-prev {
  border: none;
  border-radius: 2px;
  padding: 0;
  margin: 0 5px;
  color: #666;
  background: #f4f4f5;
  display: inline-block;
  vertical-align: top;
  font-size: 13px;
  line-height: 28px;
  min-width: 35px;
  height: 28px;
}

.el-pagination ::v-deep .btn-next {
  border: none;
  border-radius: 2px;
  padding: 0;
  margin: 0 5px;
  color: #666;
  background: #f4f4f5;
  display: inline-block;
  vertical-align: top;
  font-size: 13px;
  line-height: 28px;
  min-width: 35px;
  height: 28px;
}

.el-pagination ::v-deep .btn-prev:disabled {
  border: none;
  cursor: not-allowed;
  border-radius: 2px;
  padding: 0;
  margin: 0 5px;
  color: #C0C4CC;
  background: #f4f4f5;
  display: inline-block;
  vertical-align: top;
  font-size: 13px;
  line-height: 28px;
  height: 28px;
}

.el-pagination ::v-deep .btn-next:disabled {
  border: none;
  cursor: not-allowed;
  border-radius: 2px;
  padding: 0;
  margin: 0 5px;
  color: #C0C4CC;
  background: #f4f4f5;
  display: inline-block;
  vertical-align: top;
  font-size: 13px;
  line-height: 28px;
  height: 28px;
}

.el-pagination ::v-deep .el-pager {
  padding: 0;
  margin: 0;
  display: inline-block;
  vertical-align: top;
}

.el-pagination ::v-deep .el-pager .number {
  cursor: pointer;
  padding: 0 4px;
  margin: 0 5px;
  color: #666;
  display: inline-block;
  vertical-align: top;
  font-size: 13px;
  line-height: 28px;
  border-radius: 2px;
  background: #f4f4f5;
  text-align: center;
  min-width: 30px;
  height: 28px;
}

.el-pagination ::v-deep .el-pager .number:hover {
  cursor: pointer;
  padding: 0 4px;
  margin: 0 5px;
  color: #ff9966;
  display: inline-block;
  vertical-align: top;
  font-size: 13px;
  line-height: 28px;
  border-radius: 2px;
  background: #f4f4f5;
  text-align: center;
  min-width: 30px;
  height: 28px;
}

.el-pagination ::v-deep .el-pager .number.active {
  cursor: default;
  padding: 0 4px;
  margin: 0 5px;
  color: #FFF;
  display: inline-block;
  vertical-align: top;
  font-size: 13px;
  line-height: 28px;
  border-radius: 2px;
  background: #ff9966;
  text-align: center;
  min-width: 30px;
  height: 28px;
}

.el-pagination ::v-deep .el-pagination__sizes {
  display: inline-block;
  vertical-align: top;
  font-size: 13px;
  line-height: 28px;
  height: 28px;
}

.el-pagination ::v-deep .el-pagination__sizes .el-input {
  margin: 0 5px;
  width: 100px;
  position: relative;
}

.el-pagination ::v-deep .el-pagination__sizes .el-input .el-input__inner {
  border: 1px solid #DCDFE6;
  cursor: pointer;
  padding: 0 25px 0 8px;
  color: #606266;
  display: inline-block;
  font-size: 13px;
  line-height: 28px;
  border-radius: 3px;
  outline: 0;
  background: #FFF;
  width: 100%;
  text-align: center;
  height: 28px;
}

.el-pagination ::v-deep .el-pagination__sizes .el-input span.el-input__suffix {
  top: 0;
  position: absolute;
  right: 0;
  height: 100%;
}

.el-pagination ::v-deep .el-pagination__sizes .el-input .el-input__suffix .el-select__caret {
  cursor: pointer;
  color: #C0C4CC;
  width: 25px;
  font-size: 14px;
  line-height: 28px;
  text-align: center;
}

.el-pagination ::v-deep .el-pagination__jump {
  margin: 0 0 0 24px;
  color: #606266;
  display: inline-block;
  vertical-align: top;
  font-size: 13px;
  line-height: 28px;
  height: 28px;
}

.el-pagination ::v-deep .el-pagination__jump .el-input {
  border-radius: 3px;
  padding: 0 2px;
  margin: 0 2px;
  display: inline-block;
  width: 50px;
  font-size: 14px;
  line-height: 18px;
  position: relative;
  text-align: center;
  height: 28px;
}

.el-pagination ::v-deep .el-pagination__jump .el-input .el-input__inner {
  border: 1px solid #DCDFE6;
  cursor: pointer;
  padding: 0 3px;
  color: #606266;
  display: inline-block;
  font-size: 14px;
  line-height: 28px;
  border-radius: 3px;
  outline: 0;
  background: #FFF;
  width: 100%;
  text-align: center;
				height: 28px;
			}
</style>
